Crate icu_pattern
source ·Expand description
icu_pattern
is a utility crate of the ICU4X
project.
It includes a Pattern
type which supports patterns with various storage backends.
The types are tightly coupled with the writeable
crate.
§Examples
Parsing and interpolating with a single-placeholder pattern:
use icu_pattern::SinglePlaceholderPattern;
use writeable::assert_writeable_eq;
// Parse a pattern string:
let pattern = "Hello, {0}!"
.parse::<SinglePlaceholderPattern<_>>()
.unwrap();
// Interpolate into the pattern string:
assert_writeable_eq!(pattern.interpolate(["World"]), "Hello, World!");
// Introspect the serialized form of the pattern string:
assert_eq!(pattern.take_store(), "\x08Hello, !");
Re-exports§
pub use PatternError as Error;
Structs§
- A string wrapper for the
MultiNamedPlaceholder
pattern backend. - Placeholder pattern parser.
- Options passed to the constructor of
Parser
. - A string pattern with placeholders.
Enums§
- Backend for patterns containing zero, one, or two placeholders.
- A two-value enum for the
DoublePlaceholder
pattern backend. - Backend for patterns containing zero or more named placeholders.
- A
PatternItem
with additional detail returned by theParser
. - An error returned when parsing a pattern.
- A borrowed item in a
Pattern
. Items are either string literals or placeholders. - A borrowed-or-owned item in a
Pattern
. Items are either string literals or placeholders. - Backend for patterns containing zero or one placeholder.
- A singleton enum for the
SinglePlaceholder
pattern backend.
Constants§
- Default annotation for the literal portion of a pattern.
- Default annotation for the placeholder portion of a pattern.
Traits§
- Types that implement backing data models for
Pattern
implement this trait. - Trait implemented on collections that can produce
TryWriteable
s for interpolation.
Type Aliases§
- Examples
- Examples
- Examples